import { useEffect, useState } from 'react'
import { fetchAuditList, AuditListType, fetchList } from '../../api'
import { Table, Button } from 'antd'

export interface AuditListItem {
  'name': string,
  'createTime': string,
  'desc': string,
  'income': number,
  'type': AuditListType,
  'key': string
}



const App = () => {
  const [list, setList] = useState<AuditListItem[]>([])
  const columns = [{
    title: '姓名',
    dataIndex: 'name',
    key: 'name'
  }, {
    title: '部门',
    dataIndex: 'type',
    key: 'type'
  }, {
    title: '描述',
    dataIndex: 'desc',
    key: 'desc'
  }, {
    title: '工资',
    dataIndex: 'income',
    key: 'income'
  }, {
    title: '审核',
    key: 1,
    render(value: any) {
      return <Button type="primary">查看</Button>
    }
  }]


  // 列表请求
  const handleFetchList = async () => {
    const resp = await fetchList()
    setList(resp.data.data)
  }
 
  useEffect(() => {
    handleFetchList()
  }, [])
  return (
    <>
      <Table dataSource={list} columns={columns} ></Table>
    </>
  )
}

export default App